import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import axios from 'axios'

require('./mock/index')

axios.defaults.baseURL = 'http://apis.imooc.com/api/'
axios.interceptors.request.use(config => {
  config.params = {
    ...config.params,
    icode: '35084F3DAB9C223E'
  }
  store.commit('setLoading', true)
  store.commit('setError', {
    status: false,
    message: ''
  })
  return config
})
axios.interceptors.response.use(config => {
  setTimeout(() => {
    store.commit('setLoading', false)
  }, 2000)
  return config
}, e => {
  const { error } = e.response.data
  store.commit('setError', {
    status: true,
    message: error
  })
  store.commit('setLoading', false)
  return Promise.reject(error)
})
// axios.get('/mock/columns').then(resp => {
//   console.log(resp)
// })

createApp(App).use(store).use(router).mount('#app')
